% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/misc.R
\name{evalMacro}
\alias{evalMacro}
\title{Evaluate an expression with substitution}
\usage{
evalMacro(expr, env = parent.frame())
}
\arguments{
\item{expr}{Expression}

\item{env}{Environment used for substitution.}
}
\description{
\code{evalMacro} takes an unevaluated expression and an environment
to first substitute the specified objects and then evaluate the
resulting expression. The function \code{\link{bquote}} is used for
substitution, see the help page for substitution syntax.
}
\details{
We use \code{\link{bquote}} instead of
    \code{\link{substitute}} to force an explicit syntax
    highlighting which objects should be substituted. The resulting
    expression is then evaluated within the context of the parent
    environment (see: \code{\link{parent.frame}}).
}
\examples{
x <- 1
expr <- quote(.(a) + 1)

evalMacro(expr, list(a = x))

df <- data.frame(x = c(1, 2, 3))
transform(df, y = evalMacro(expr, list(a = x)))

}
